package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.Client;
import com.indusfo.spc.service.ClientService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/service/client")
public class ClientController {

    @Autowired
    private ClientService clientService;

    /**
     * 修改客户端设置
     *
     * @param client
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value = "/updateClient",method= RequestMethod.POST)
    @SystemControllerLog(description="修改客户端设置")
    @ResponseBody
    public JSONObject updateClient (Client client){

        JSONObject json=clientService.updateClient(client);

        return json;
    }

    /**
     * 查询
     *
     * @param client
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryClient")
    @SystemControllerLog(description="查询客户端设置")
    @ResponseBody
    public JSONObject queryClient(Client client) {

        JSONObject json = clientService.selectAll(client);
        return json;

    }

    /**
     * 新增
     *
     * @param client
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertClient", method= RequestMethod.POST)
    @SystemControllerLog(description="新增客户端设置")
    @ResponseBody
    public JSONObject insertClient(Client client) {

        JSONObject json = clientService.insertBldc(client);
        return json;
    }

    /**
     * 启用/停用
     *
     * @param clientIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definedClient", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用客户端设置")
    @ResponseBody
    public JSONObject definedClient(Long[] clientIds, Integer dataState) {

        JSONObject json = clientService.deleteClient(clientIds, dataState);
        return json;
    }

    /**
     * 删除
     *
     * @param clientIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteClient", method= RequestMethod.POST)
    @SystemControllerLog(description="删除客户端设置")
    @ResponseBody
    public JSONObject deleteClient(Long[] clientIds, Integer dataState) {

        dataState = 2;
        JSONObject json = clientService.deleteClient(clientIds, dataState);
        return json;
    }
}
